#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Video Classifier Application
Launch script for the video classification tool
"""

import sys
import tkinter as tk
import os
from src.gui.main_window import MainWindow
from src.utils.logger import log_error, log_info

# Add the project root to the path if running as a script
if __name__ == "__main__":
    project_root = os.path.dirname(os.path.abspath(__file__))
    if project_root not in sys.path:
        sys.path.insert(0, project_root)


    # 创建全局异常处理器
    def handle_exception(exc_type, exc_value, exc_traceback):
        log_error("未捕获的异常", ext=(exc_type, exc_value, exc_traceback))
        if 'app' in globals() and app:
            app.update_log(f"发生错误: {exc_value}")

    sys.excepthook = handle_exception

    log_info("应用启动", ext=sys.argv)
    # 启动应用
    root = tk.Tk()
    app = MainWindow(root)
    root.mainloop()
